package com.dalin.framework.listeners;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.dalin.common.utils.LcnUtils;
import com.dalin.common.utils.StringUtils;

/*****************************************************************************
 * @content: spring 加载管理                                                                                                               *
 * @author : 那建林                                                                                                                                 *
 * @crtDate: 2010-04-26                                                     *
 * @version: 1.1                                                            *
 ****************************************************************************/
public class StartupListener extends ContextLoaderListener implements ServletContextListener {
	static ApplicationContext APPLICATION_CONTEXT = null;
	public void contextInitialized(ServletContextEvent event) {
		//验证license
		String errorInfo = LcnUtils.examineLicByDate();
		if (!StringUtils.isBlank(errorInfo)) {
			System.out.println(errorInfo);
			return;
		}
	    super.contextInitialized(event);
	    ServletContext context = event.getServletContext();
	    APPLICATION_CONTEXT = WebApplicationContextUtils
	    		.getRequiredWebApplicationContext(context);
	}
}
